package com.bpr.webservice.domain.dto;

import java.util.List;

import com.bpr.webservice.domain.Menuaccess;
import com.bpr.webservice.domain.Usergroups;
import com.bpr.webservice.domain.Users;
import com.fasterxml.jackson.annotation.JsonAutoDetect;

@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) 
public class UserDto {

	private Long userid;
	private String username;
	private String passwd;
	private char enabled;
	private Usergroups usergroup;
	private List<Menuaccess> menuaccesses;
	public UserDto() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Long getUserid() {
		return userid;
	}
	public void setUserid(Long userid) {
		this.userid = userid;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPasswd() {
		return passwd;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	public char getEnabled() {
		return enabled;
	}
	public void setEnabled(char enabled) {
		this.enabled = enabled;
	}
	
	public Usergroups getUsergroup() {
		return usergroup;
	}
	public void setUsergroup(Usergroups usergroup) {
		this.usergroup = usergroup;
	}
	public List<Menuaccess> getMenuaccesses() {
		return menuaccesses;
	}
	public void setMenuaccesses(List<Menuaccess> menuaccesses) {
		this.menuaccesses = menuaccesses;
	}
	
	public void constructDto(Users user){
		if (user.getUserid() != null){
			this.setUserid(user.getUserid());
		}
		this.setUsername(user.getUsername());
		this.setPasswd(user.getPasswd());
		this.setEnabled(user.getEnabled());
		if(user.getUsergroupid() != null){
			user.getUsergroupid().getUsergroupname();
			this.setUsergroup(user.getUsergroupid());
		}
		if (user.getMenuaccessList() != null){
			user.getMenuaccessList().size();
			this.setMenuaccesses(user.getMenuaccessList());
		}
	}
	
}
